package com.xxx.coll;

import java.util.ArrayList;
import java.util.List;

/**
 * @version v1.0
 * @Description:
 * @Author zhanzhongxin
 * @Date 2021/7/20 14:26
 * @Copyright 博为峰
 */
public class ListDemo {
    public static void main(String[] args) {
//        add();
//        remove();
//        set();
//        get();
        List list = new ArrayList();
        list.add("a");
        list.add("b");
        list.add("c");//[a, b, c]
        list.add("a");
        System.out.println(list);
    }

    public static void get() {
        List list = new ArrayList();
        list.add("a");
        list.add("b");
        list.add("c");//[a, b, c]
        System.out.println(list.get(1));
        System.out.println(list.indexOf("b"));
        System.out.println(list.lastIndexOf("bb"));
    }

    public static void set() {
        List list = new ArrayList();
        list.add("a");
        list.add("b");
        list.add("c");//[a, b, c]
        list.set(1, "B");
        System.out.println(list);
    }

    public static void remove() {
        List list = new ArrayList();
        list.add("a");
        list.add("b");
        list.add("c");//[a, b, c]
        list.add(1, "d");//[a, d, b, c]
        list.remove(1);
        System.out.println(list);
    }

    public static void add() {
        List list = new ArrayList();
        list.add("a");
        list.add("b");
        list.add("c");//[a, b, c]
        list.add(1, "d");//[a, d, b, c]
        System.out.println(list);
    }
}
